package com.ccl.iot.dvr.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.ccl.iot.managers.Manager;

public class DBManager {
    private static DBManager manager;
    private DBHelper mDBHelper;
    private SQLiteDatabase db;

    /**
     * 私有化构造器
     */
    private DBManager(Context context) {
        //创建数据库
    	mDBHelper = DBHelper.getInstance(context);
        if (db == null) {
            db = mDBHelper.getWritableDatabase();
        }
    }

    /**
     * 单例DbManager类
     *
     * @return 返回DbManager对象
     */
    public static DBManager newInstances(Context context) {
        if (manager == null) {
            manager = new DBManager(context);

            //数据库保存在内存卡
//            manager = new DBManager(Manager.DBCONTEXT);
        }
        return manager;
    }

    /**
     * 获取数据库的对象
     *
     * @return 返回SQLiteDatabase数据库的对象
     */
    public SQLiteDatabase getDataBase() {
        return db;
    }
}